<?php 

class Prestamos_model extends CI_Model{ 
	private $_tabla = 'prestamos';
	public $idPrestamo = 0;
    public $dni = 0;
    public $idLibro = 0;
    public $fechaPrestamo = 0;
    public $fechaDevolucion = 0;
    public $fechaDevuelto = 0;
    public $fechaRenovacion = 0;
    public $tipoPrestamo = 0;
    public $renovado = false;
    public $estado = true;

    public function getAll(){
    	return $this->db->get($this->_tabla)->result_array();
    }
    public function insert(){
    	$this->db->insert($this->_tabla,$this);
    }

    public function update(){
		$this->db->where('idPrestamo', $this->idPrestamo);
		$this->db->update($this->_tabla,$this);
	}
	public function getById($id){
	$query = $this->db->query("SELECT * FROM " . $this->_tabla . " WHERE idPrestamo = '" . $id . "'");

	 foreach ($query->result() as $row)
	 {
		return $row;
	 }
    }


}


  ?>



